package com.qiaodata.datatrans.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2016/12/20 0020.
 */
public class TimeUtil {

    //时间戳转日期字符串yyyy.MM.dd
    public static String getDateStr(Long timeTmp) {
        SimpleDateFormat format =  new SimpleDateFormat("yyyy.MM.dd");
        Long aLong = new Long(timeTmp.toString()+"000");
        Date date = new Date(aLong);
        String d = format.format(date);
        return d;
    }

    //时间戳转日期字符串yyyy
    public static String getDateYYYYStr(Long timeTmp) {
        SimpleDateFormat format =  new SimpleDateFormat("yyyy");
        Long aLong = new Long(timeTmp.toString()+"000");
        Date date = new Date(aLong);
        String d = format.format(date);
        return d;
    }

    //日期转时间戳ObtainTime
    public static Long getDateTmp(String timeStr) throws ParseException {
        SimpleDateFormat format =  new SimpleDateFormat("yyyy");
        Date parse = format.parse(timeStr);
        long dateTmp = parse.getTime() / 1000;
        return dateTmp;
    }
}
